﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Configuration;
using ElectronicRecords.Models;
using ElectronicRecords.Controllers;
namespace ElectronicRecords.Core
{
    public class ElectronicRecordsControllerFactory:DefaultControllerFactory
    {
        protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
        {
            
            string connectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            if(controllerType==null)
            {
                
               // return Activator.CreateInstance(, new DataManager(connectionString)) as IController;
                return Activator.CreateInstance(typeof(HomeController), new DataManager(connectionString)) as IController;

            }
            else
            {
                return Activator.CreateInstance(controllerType, new DataManager(connectionString)) as IController;
            }
            
            
        }
    }
}